<cfprocessingdirective suppresswhitespace="yes">
<!--- 
***** REVISION *****
10/18/06: This is a new tag
 --->
 	
<cfswitch expression="#thisTag.executionMode#">
	<cfcase value="start">		
		<cfset tag = "select"/>
		
		<cfsavecontent variable="attributeCombination">
		<strong>Possible Attribute Combinations are:</strong>
		<LI>Required attributes: QUERY, VALUE or OPTION.</LI>
		<LI>Required attributes: TABLE, DSN, VALUE or OPTION.  Optional attributes: COLUMNLIST, SORT, ORDER, RESULT.</LI>
		<LI>Required attributes: SQL, DSN, VALUE or OPTION.  Optional attributes: RESULT.</LI>
		<LI>Required attributes: LIST.  Optional attributes: VALUEDELIMITERS, DELIMITERS.</LI>
		<LI>Required attributes: VALUELIST or OPTIONLIST.  Optional attributes: VALUEDELIMITERS, DELIMITERS.</LI>
		<LI>Required attributes: ARRAY.</LI>
		<LI>Required attributes: VALUEARRAY or OPTIONARRAY.</LI>
		<strong>Common Attributes Among All Possible Attribute Combinations Above Are:</strong><br/> 
		Required attributes: NAME, or ID, or FORLABEL. Optional attributes: LABEL, CLASSLABEL, CHECKVALUE, VALUEHEADER, OPTIONHEADER, BREAK, CSS.
		</cfsavecontent>

		<cfinclude template="inc/start.cfm"/>	
		<cfinclude template="inc/optionList.cfm"/>
		<cfset excludes = excludes & "id"/>
		<!--- process VALUE --->
		<cfset config.selectedValue = parent.processValue(config.checkValue,caller,attributes,config)/>

		<!--- CFPARAM the "maybe" missing variables --->
		<cfif structKeyExists(config,'value')>
			<cfparam name="config.option" default="#config.value#"/>
		<cfelseif structKeyExists(config,'option')>
			<cfparam name="config.value" default="#config.option#"/>
						
		<cfelseif structKeyExists(config,'valueList')>
			<cfparam name="config.optionList" default="#config.valueList#"/>
		<cfelseif structKeyExists(config,'optionList')>
			<cfparam name="config.valueList" default="#config.optionList#"/>
			
		<cfelseif structKeyExists(config,'valueArray')>
			<cfparam name="config.optionArray" default="#config.valueArray#"/>
		<cfelseif structKeyExists(config,'optionArray')>
			<cfparam name="config.valueArray" default="#config.optionArray#"/>
		</cfif>

		<!--- Map the variables to its caller scope --->
		<cfif structKeyExists(config,'query')>
			<cfset config.query = parent.exists(config.query,caller)/>
			
		<cfelseif structKeyExists(config,'table')>
			<cfif listLen(config.option,'&') gt 1 and not structKeyExists(config,'columnList')>
				<cfset parent.showException(tag,'COLUMNLIST attribute must be used  with the TABLE attribute to specify the merging columns in the OPTION attribute.',3,attributeCombination)/>						
			</cfif>
			<cfparam name="config.sort" default="#config.value#"/>
			<cfparam name="config.order" default="asc"/>
			<cfquery datasource="#config.dsn#" name="config.query">
				SELECT
					#CONFIG.VALUE#,
					<cfif structKeyExists(config,'columnList')>
					#CONFIG.COLUMNLIST#
					<cfelse>
					#CONFIG.OPTION#
					</cfif>
				FROM
					#CONFIG.TABLE#
				ORDER BY
					#CONFIG.SORT# <cfif listlen(trim(config.sort),' ') eq 1>#CONFIG.ORDER#</cfif>
			</cfquery>
			
		<cfelseif structKeyExists(config,'list')>
			<cfset config.list = parent.exists(config.list,caller,false)/>
			<cfparam name="config.delimiters" default=","/>
			<cfparam name="config.valueDelimiters" default=":"/>
						
		<cfelseif structKeyExists(config,'valueList') and structKeyExists(config,'optionList')>
			<cfset config.valueList = parent.exists(config.valueList,caller,false)/>
			<cfset config.optionList = parent.exists(config.optionList,caller,false)/>
	
			<cfif listLen(config.valueList) neq listLen(config.optionList)>
				<cfset parent.showException(tag,'The lists in VALUELIST and OPTIONLIST must be of the same length.')/>										
			</cfif>
			
			<cfif structKeyExists(config,'delimiters')>
				<cfparam name="config.valueDelimiters" default="#config.delimiters#"/>			
			</cfif>
			<cfif structKeyExists(config,'valueDelimiters')>
				<cfparam name="config.delimiters" default="#config.valueDelimiters#"/>			
			</cfif>
			<cfparam name="config.delimiters" default=","/>			
			<cfparam name="config.valueDelimiters" default=","/>
			
		<cfelseif structKeyExists(config,'array')>
			<cfset config.array = parent.exists(config.array,caller)/>
			
		<cfelseif structKeyExists(config,'valueArray') and structKeyExists(config,'optionArray')>
			<cfset config.valueArray = parent.exists(config.valueArray,caller)/>
			<cfset config.optionArray = parent.exists(config.optionArray,caller)/>
			
			<cfif arrayLen(config.valueArray) neq arrayLen(config.optionArray)>
				<cfset parent.showException(tag,'The arrays in VALUEARRAY and OPTIONARRAY must be of the same length.')/>										
			</cfif>
		</cfif>

		<cfif structKeyExists(config,'valueHeader')>
			<cfparam name="config.optionHeader" default="Select..."/>
		<cfelseif structKeyExists(config,'optionHeader')>
			<cfparam name="config.valueHeader" default=""/>		
		</cfif>
	</cfcase>
	
	
	<cfcase value="end">
		<cfinclude template="inc/sql.cfm"/>		
		<cfinclude template="inc/field.cfm"/>
	</cfcase>
</cfswitch>
</cfprocessingdirective>